package com.a3g.findnumber;

import java.util.ArrayList;


import com.a3g.findnumber.entity.CustomGridViewAdapter;
import com.a3g.findnumber.entity.Item;


import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;


/**
 * @author Administrator
 *
 */
public class ChoiceLevelAct extends Activity {

	GridView gridView;

	ArrayList<Item> gridArray = new ArrayList<Item>();

	CustomGridViewAdapter customGridAdapter;

	

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.choice_level);
		
		// set grid view item
		Bitmap homeIcon = BitmapFactory.decodeResource(this.getResources(),R.drawable.level_01_button);
		int maxRow = 15;
		
		for (int i = 0; i < maxRow; i++) {
			gridArray.add(new Item(homeIcon,"level_01_button"));
		}
		
		gridView = (GridView) findViewById(R.id.levelGridView);
		customGridAdapter = new CustomGridViewAdapter(this, R.layout.row_grid, gridArray);
		int numColumns = 5;
		gridView.setNumColumns(numColumns);
		gridView.setAdapter(customGridAdapter);
		
		gridView.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View v,
				int position, long id) {
			  
			  Toast.makeText(getApplicationContext(), position + "#Selected", Toast.LENGTH_SHORT).show();
			  
			  Intent playIntent = new Intent(getApplicationContext(), GamePlayAct.class);
				startActivity(playIntent);
			}
    	});
	}
	
}

	

	

	




